# coding=utf-8
import feedparser

if __name__ == '__main__':
    url = 'http://feeds.qzone.qq.com/cgi-bin/cgi_rss_out?uin=81715239' #'http://fengmk2.cnblogs.com/rss/'
    d = feedparser.parse(url)
    print d.feed.title
    print d.feed.description #rss
    print d.feed.subtitle #atom
    print d.feed.link
    print d.feed.date #rss
    print d.feed.updated #atom
    print d.feed.date_parsed
    #print d.feed.cloud
    #print d.feed.categories
    if d.feed.has_key('id'): #atom
        print d.feed.id
    print d.feed.get('id', 'no id')
    print len(d.entries)
    print d.entries[0].title
    print d.entries[0].link
    #print d.entries[0].description
    print d.entries[0].date
    print d.entries[0].id
    
    print '----------------etag---------------------------'
    print d.status
    #print d.debug_message
    print d.etag
    
    d2 = feedparser.parse(url, etag=d.etag)
    print d2.status
    print d2.etag
    
    print '----------------last-modified---------------------------'
    print d.modified
    import time
    testdd = time.struct_time((2008, 2, 28, 2, 40, 43, 3, 59, 0))
    print testdd
    d3 = feedparser.parse(url, modified=d.modified)
    print d3.status
    print d3.debug_message
    
    d4 = feedparser.parse(url, modified=testdd)
    print d4.status
    print d4.debug_message